#!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time    : 2020/2/22 13:00
# @Author  : HaoXuan
# @Email   : 879316712@qq.com
# @File    : 瓜子二手车数据采集.py
# @Software: PyCharm
import requests
import io
import sys
from lxml import etree

sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='gb18030')#改变标准输出的默认代码

headers={'User-Agent':' Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36',
'Cookie': 'track_id=46944110665416704; uuid=44006bd5-0d01-4eb2-a4fd-68bf8a299797; clueSourceCode=%2A%2300; ganji_uuid=4557160798931150556460; sessionid=b9845e73-923f-4fc7-fa38-865fc93bbf56; lg=1; cainfo=%7B%22ca_a%22%3A%22-%22%2C%22ca_b%22%3A%22-%22%2C%22ca_s%22%3A%22pz_baidu%22%2C%22ca_n%22%3A%22pcbiaoti%22%2C%22ca_medium%22%3A%22-%22%2C%22ca_term%22%3A%22-%22%2C%22ca_content%22%3A%22%22%2C%22ca_campaign%22%3A%22%22%2C%22ca_kw%22%3A%22-%22%2C%22ca_i%22%3A%22-%22%2C%22scode%22%3A%22-%22%2C%22keyword%22%3A%22-%22%2C%22ca_keywordid%22%3A%22-%22%2C%22ca_transid%22%3A%22%22%2C%22platform%22%3A%221%22%2C%22version%22%3A1%2C%22track_id%22%3A%2246944110665416704%22%2C%22display_finance_flag%22%3A%22-%22%2C%22client_ab%22%3A%22-%22%2C%22guid%22%3A%2244006bd5-0d01-4eb2-a4fd-68bf8a299797%22%2C%22ca_city%22%3A%22xianyang%22%2C%22sessionid%22%3A%22b9845e73-923f-4fc7-fa38-865fc93bbf56%22%7D; financeCityDomain=all; jr_from=web_index_tc; jr_apply_platform=web; 44006bd5-0d01-4eb2-a4fd-68bf8a299797_views=1; b9845e73-923f-4fc7-fa38-865fc93bbf56_views=1; jr_client=pc; Hm_lvt_e6e64ec34653ff98b12aab73ad895002=1582347557; Hm_lpvt_e6e64ec34653ff98b12aab73ad895002=1582347557; close_finance_popup=2020-02-22; cityDomain=cs; user_city_id=204; preTime=%7B%22last%22%3A1582347621%2C%22this%22%3A1582347548%2C%22pre%22%3A1582347548%7D; antipas=8679808ZX6A79a618Ad5q988g80'
}

url = 'https://www.guazi.com/cs/buy/o1/'
# resp = requests.get(url,headers=headers).content
# html=resp.decode('utf-8')
#发送请求返回网页内容
def getHTMLtext(url):
    try:
        html = requests.get(url,headers=headers).content
        html = html.decode('utf-8')
        return html
    except:
        return '产生异常'
#数据的提取
def get_data(html):
    pass


def main():
    start_url= 'https://www.guazi.com/cs/buy/o1/'
    html = getHTMLtext(start_url)
    print(html)

main()